package p100;

import java.util.ArrayList;
import java.util.List;

public class Leetcode_118 {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> lists = new ArrayList<>();
        for (int i = 1; i <= numRows; i++) {
            List<Integer> list = new ArrayList<>();
            for (int j = 1; j <= i; j++) {
                if (list.size() == 0 || list.size() == i - 1) {
                    list.add(1);
                } else {
                    list.add(lists.get(lists.size() - 1).get(j - 2) + lists.get(lists.size() - 1).get(j - 1));
                }
            }
            lists.add(list);
        }
        return lists;
    }

    public static void main(String[] args) {
        Leetcode_118 l = new Leetcode_118();
        System.out.println(l.generate(5));
    }
}
